﻿namespace HRM.CORE.Process
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Grid;
    using APP.HELPER;
    using HRM.CORE;
    
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using Dictionary.ERP;
    using APP.HELPER.Utils.Language;
    using Security.ERP;

    public class xucPositionAdd : Common.xucBaseAddH
    {
        private ComboBoxEdit cboBranch;
        private TextEdit cboDecideNumber;
        private ComboBoxEdit cboDepartment;
        private ComboBoxEdit cboGroup;
        private TextEdit cboPerson;
        private ComboBoxEdit cboPosition;
        private GridColumn colEmployeeCode;
        private GridColumn colFirstName;
        private GridColumn colLastName;
        private IContainer components = null;
        private DateEdit dtDate;
        private GridLookUpEdit glkBranch;
        private GridLookUpEdit glkDepartment;
        private GridLookUpEdit glkEmployeeCode;
        private GridLookUpEdit glkGroup;
        private GridColumn gridColumn10;
        private GridColumn gridColumn5;
        private GridColumn gridColumn6;
        private GridColumn gridColumn7;
        private GridColumn gridColumn8;
        private GridColumn gridColumn9;
        private GridView gridLookUpEdit1View;
        private GridView gridView1;
        private GridView gridView4;
        private GridView gridView5;
        private GroupControl grInformation;
        private GroupBox grNew;
        private GroupBox grOld;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl5;
        private LabelControl lcDate;
        private LabelControl lcDecideNumber;
        private LabelControl lcPerson;
        private LabelControl lcReason;
        private string m_EmployeeCode = "";
        private Guid m_PositionID = Guid.Empty;
        private TextEdit txtEmployeeName;
        private TextEdit txtPosition;
        private MemoEdit txtReason;

        public event SuccessEventHander Success;

        public xucPositionAdd()
        {
            this.InitializeComponent();
            this.InitComponent();
            this.InitData();
        }

        protected override void Add()
        {
            base.Add();
            HRM_PROCESS_POSITION hrm_process_position = new HRM_PROCESS_POSITION();
        }

        public void Clear()
        {
            this.cboPosition.Text = "";
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void glk_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Kind == ButtonPredefines.Glyph)
            {
                GridLookUpEdit edit = sender as GridLookUpEdit;
                string name = edit.Name;
                if (((name != null) && (name == "glkGroup")) && (e.Button.Caption != "Add"))
                {
                    this.glkGroup.EditValue = null;
                }
            }
        }

        private void glkBranch_EditValueChanged(object sender, EventArgs e)
        {
            new HRM_DEPARTMENT().AddGridLookupEdit(this.glkDepartment, this.glkBranch.Properties.View.GetFocusedRowCellValue("BranchCode").ToString(), "DepartmentName");
        }

        private void glkDepartment_EditValueChanged(object sender, EventArgs e)
        {
            new HRM_GROUP().AddGridLookupEdit(this.glkGroup, this.glkDepartment.Properties.View.GetFocusedRowCellValue("DepartmentCode").ToString(), "GroupName");
            if (this.glkGroup.Text == "")
            {
                this.glkGroup.EditValue = null;
            }
        }

        private void glkEmployeeCode_EditValueChanged(object sender, EventArgs e)
        {
            this.m_EmployeeCode = this.glkEmployeeCode.EditValue.ToString();
            this.LoadEmployeeInformation();
        }

        protected override void Init()
        {
        }

        private void InitComponent()
        {
            this.dtDate.DateTime = DateTime.Now;
        }

        private void InitData()
        {
            new HRM_BRANCH().AddGridLookupEdit(this.glkBranch, "BranchName");
            new DIC_POSITION().AddComboEdit(this.cboPosition);
            new HRM_EMPLOYEE().AddGridLookupEdit(this.glkEmployeeCode);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xucPositionAdd));
            SerializableAppearanceObject appearance = new SerializableAppearanceObject();
            this.grInformation = new GroupControl();
            this.labelControl1 = new LabelControl();
            this.txtEmployeeName = new TextEdit();
            this.glkEmployeeCode = new GridLookUpEdit();
            this.gridView1 = new GridView();
            this.colEmployeeCode = new GridColumn();
            this.colFirstName = new GridColumn();
            this.colLastName = new GridColumn();
            this.dtDate = new DateEdit();
            this.lcDate = new LabelControl();
            this.grNew = new GroupBox();
            this.labelControl5 = new LabelControl();
            this.labelControl2 = new LabelControl();
            this.glkBranch = new GridLookUpEdit();
            this.gridLookUpEdit1View = new GridView();
            this.gridColumn5 = new GridColumn();
            this.gridColumn6 = new GridColumn();
            this.glkDepartment = new GridLookUpEdit();
            this.gridView4 = new GridView();
            this.gridColumn7 = new GridColumn();
            this.gridColumn8 = new GridColumn();
            this.glkGroup = new GridLookUpEdit();
            this.gridView5 = new GridView();
            this.gridColumn9 = new GridColumn();
            this.gridColumn10 = new GridColumn();
            this.cboPosition = new ComboBoxEdit();
            this.grOld = new GroupBox();
            this.txtPosition = new TextEdit();
            this.cboGroup = new ComboBoxEdit();
            this.cboDepartment = new ComboBoxEdit();
            this.cboBranch = new ComboBoxEdit();
            this.lcReason = new LabelControl();
            this.lcDecideNumber = new LabelControl();
            this.lcPerson = new LabelControl();
            this.cboDecideNumber = new TextEdit();
            this.cboPerson = new TextEdit();
            this.txtReason = new MemoEdit();
            ((ISupportInitialize) base.Err).BeginInit();
            base.imageCollection2.BeginInit();
            this.grInformation.BeginInit();
            this.grInformation.SuspendLayout();
            this.txtEmployeeName.Properties.BeginInit();
            this.glkEmployeeCode.Properties.BeginInit();
            this.gridView1.BeginInit();
            this.dtDate.Properties.VistaTimeProperties.BeginInit();
            this.dtDate.Properties.BeginInit();
            this.grNew.SuspendLayout();
            this.glkBranch.Properties.BeginInit();
            this.gridLookUpEdit1View.BeginInit();
            this.glkDepartment.Properties.BeginInit();
            this.gridView4.BeginInit();
            this.glkGroup.Properties.BeginInit();
            this.gridView5.BeginInit();
            this.cboPosition.Properties.BeginInit();
            this.grOld.SuspendLayout();
            this.txtPosition.Properties.BeginInit();
            this.cboGroup.Properties.BeginInit();
            this.cboDepartment.Properties.BeginInit();
            this.cboBranch.Properties.BeginInit();
            this.cboDecideNumber.Properties.BeginInit();
            this.cboPerson.Properties.BeginInit();
            this.txtReason.Properties.BeginInit();
            base.SuspendLayout();
            base.btnSave.Location = new Point(0x127, 0x139);
            base.btnSave.TabIndex = 1;
            base.btnCancel.Location = new Point(0x1ee, 0x139);
            base.btnCancel.TabIndex = 3;
            base.btnSaveNew.Location = new Point(0x189, 0x139);
            base.btnSaveNew.TabIndex = 2;
            base.imageCollection2.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection2.ImageStream");
            this.grInformation.Controls.Add(this.labelControl1);
            this.grInformation.Controls.Add(this.txtEmployeeName);
            this.grInformation.Controls.Add(this.glkEmployeeCode);
            this.grInformation.Controls.Add(this.dtDate);
            this.grInformation.Controls.Add(this.lcDate);
            this.grInformation.Controls.Add(this.grNew);
            this.grInformation.Controls.Add(this.grOld);
            this.grInformation.Controls.Add(this.lcReason);
            this.grInformation.Controls.Add(this.lcDecideNumber);
            this.grInformation.Controls.Add(this.lcPerson);
            this.grInformation.Controls.Add(this.cboDecideNumber);
            this.grInformation.Controls.Add(this.cboPerson);
            this.grInformation.Controls.Add(this.txtReason);
            this.grInformation.Dock = DockStyle.Top;
            this.grInformation.Location = new Point(0, 0);
            this.grInformation.Name = "grInformation";
            this.grInformation.Size = new Size(0x25b, 0x131);
            this.grInformation.TabIndex = 0;
            this.grInformation.Text = "Th\x00f4ng Tin Thay Đổi Chức Vụ";
            this.labelControl1.AllowHtmlString = true;
            this.labelControl1.Location = new Point(14, 0x25);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x60, 14);
            this.labelControl1.TabIndex = 0;
            this.labelControl1.Text = "Chọn nh\x00e2n vi\x00ean <color=red>(*)</color>:";
            this.txtEmployeeName.Enabled = false;
            this.txtEmployeeName.Location = new Point(0x11c, 0x22);
            this.txtEmployeeName.Name = "txtEmployeeName";
            this.txtEmployeeName.Size = new Size(0x131, 20);
            this.txtEmployeeName.TabIndex = 2;
            this.glkEmployeeCode.Location = new Point(0x77, 0x22);
            this.glkEmployeeCode.Name = "glkEmployeeCode";
            this.glkEmployeeCode.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.glkEmployeeCode.Properties.NullText = "[Chọn nh\x00e2n vi\x00ean]";
            this.glkEmployeeCode.Properties.View = this.gridView1;
            this.glkEmployeeCode.Size = new Size(0x9b, 20);
            this.glkEmployeeCode.TabIndex = 1;
            this.glkEmployeeCode.EditValueChanged += new EventHandler(this.glkEmployeeCode_EditValueChanged);
            this.gridView1.Columns.AddRange(new GridColumn[] { this.colEmployeeCode, this.colFirstName, this.colLastName });
            this.gridView1.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.colEmployeeCode.Caption = "M\x00e3 nh\x00e2n vi\x00ean";
            this.colEmployeeCode.FieldName = "EmployeeCode";
            this.colEmployeeCode.Name = "colEmployeeCode";
            this.colEmployeeCode.Visible = true;
            this.colEmployeeCode.VisibleIndex = 0;
            this.colFirstName.Caption = "Họ l\x00f3t";
            this.colFirstName.FieldName = "FirstName";
            this.colFirstName.Name = "colFirstName";
            this.colFirstName.Visible = true;
            this.colFirstName.VisibleIndex = 1;
            this.colLastName.Caption = "T\x00ean";
            this.colLastName.FieldName = "LastName";
            this.colLastName.Name = "colLastName";
            this.colLastName.Visible = true;
            this.colLastName.VisibleIndex = 2;
            this.dtDate.EditValue = null;
            this.dtDate.Location = new Point(0x101, 0x111);
            this.dtDate.Name = "dtDate";
            this.dtDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtDate.Size = new Size(90, 20);
            this.dtDate.TabIndex = 10;
            this.lcDate.Location = new Point(0xb5, 0x113);
            this.lcDate.Name = "lcDate";
            this.lcDate.Size = new Size(0x47, 13);
            this.lcDate.TabIndex = 9;
            this.lcDate.Text = "Ng\x00e0y thay đổi:";
            this.grNew.Controls.Add(this.labelControl5);
            this.grNew.Controls.Add(this.labelControl2);
            this.grNew.Controls.Add(this.glkBranch);
            this.grNew.Controls.Add(this.glkDepartment);
            this.grNew.Controls.Add(this.glkGroup);
            this.grNew.Controls.Add(this.cboPosition);
            this.grNew.Location = new Point(0x11c, 60);
            this.grNew.Name = "grNew";
            this.grNew.Size = new Size(0x131, 0x9a);
            this.grNew.TabIndex = 4;
            this.grNew.TabStop = false;
            this.grNew.Text = "Mới";
            this.labelControl5.AllowHtmlString = true;
            this.labelControl5.Location = new Point(11, 0x7b);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(14, 14);
            this.labelControl5.TabIndex = 5;
            this.labelControl5.Text = "<color=red>(*)</color>";
            this.labelControl2.AllowHtmlString = true;
            this.labelControl2.Location = new Point(11, 0x1c);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(14, 14);
            this.labelControl2.TabIndex = 0;
            this.labelControl2.Text = "<color=red>(*)</color>";
            this.glkBranch.Location = new Point(30, 0x19);
            this.glkBranch.Name = "glkBranch";
            this.glkBranch.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.glkBranch.Properties.NullText = "";
            this.glkBranch.Properties.NullValuePrompt = "[Chọn chi nh\x00e1nh]";
            this.glkBranch.Properties.NullValuePromptShowForEmptyValue = true;
            this.glkBranch.Properties.View = this.gridLookUpEdit1View;
            this.glkBranch.Size = new Size(0x108, 20);
            this.glkBranch.TabIndex = 1;
            this.glkBranch.EditValueChanged += new EventHandler(this.glkBranch_EditValueChanged);
            this.gridLookUpEdit1View.Columns.AddRange(new GridColumn[] { this.gridColumn5, this.gridColumn6 });
            this.gridLookUpEdit1View.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridLookUpEdit1View.Name = "gridLookUpEdit1View";
            this.gridLookUpEdit1View.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridLookUpEdit1View.OptionsView.ShowGroupPanel = false;
            this.gridColumn5.Caption = "M\x00e3 chi nh\x00e1nh";
            this.gridColumn5.FieldName = "BranchCode";
            this.gridColumn5.Name = "gridColumn5";
            this.gridColumn5.Visible = true;
            this.gridColumn5.VisibleIndex = 0;
            this.gridColumn6.Caption = "T\x00ean chi nh\x00e1nh";
            this.gridColumn6.FieldName = "BranchName";
            this.gridColumn6.Name = "gridColumn6";
            this.gridColumn6.Visible = true;
            this.gridColumn6.VisibleIndex = 1;
            this.glkDepartment.Location = new Point(30, 0x39);
            this.glkDepartment.Name = "glkDepartment";
            this.glkDepartment.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.glkDepartment.Properties.NullText = "";
            this.glkDepartment.Properties.NullValuePrompt = "[Chọn ph\x00f2ng ban thuộc chi nh\x00e1nh]";
            this.glkDepartment.Properties.NullValuePromptShowForEmptyValue = true;
            this.glkDepartment.Properties.View = this.gridView4;
            this.glkDepartment.Size = new Size(0x108, 20);
            this.glkDepartment.TabIndex = 3;
            this.glkDepartment.EditValueChanged += new EventHandler(this.glkDepartment_EditValueChanged);
            this.gridView4.Columns.AddRange(new GridColumn[] { this.gridColumn7, this.gridColumn8 });
            this.gridView4.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridView4.Name = "gridView4";
            this.gridView4.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridView4.OptionsView.ShowGroupPanel = false;
            this.gridColumn7.Caption = "M\x00e3 ph\x00f2ng ban";
            this.gridColumn7.FieldName = "DepartmentCode";
            this.gridColumn7.Name = "gridColumn7";
            this.gridColumn7.Visible = true;
            this.gridColumn7.VisibleIndex = 0;
            this.gridColumn8.Caption = "T\x00ean ph\x00f2ng ban";
            this.gridColumn8.FieldName = "DepartmentName";
            this.gridColumn8.Name = "gridColumn8";
            this.gridColumn8.Visible = true;
            this.gridColumn8.VisibleIndex = 1;
            this.glkGroup.Location = new Point(30, 0x59);
            this.glkGroup.Name = "glkGroup";
            this.glkGroup.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo), new EditorButton(ButtonPredefines.Glyph, "Delete", -1, true, true, false, ImageLocation.MiddleCenter, (Image) manager.GetObject("glkGroup.Properties.Buttons"), new KeyShortcut(Keys.None), appearance, "", null, null, true) });
            this.glkGroup.Properties.NullText = "";
            this.glkGroup.Properties.NullValuePrompt = "[Chọn tổ nh\x00f3m thuộc ph\x00f2ng ban]";
            this.glkGroup.Properties.NullValuePromptShowForEmptyValue = true;
            this.glkGroup.Properties.View = this.gridView5;
            this.glkGroup.Size = new Size(0x108, 0x16);
            this.glkGroup.TabIndex = 4;
            this.glkGroup.ButtonClick += new ButtonPressedEventHandler(this.glk_ButtonClick);
            this.gridView5.Columns.AddRange(new GridColumn[] { this.gridColumn9, this.gridColumn10 });
            this.gridView5.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridView5.Name = "gridView5";
            this.gridView5.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridView5.OptionsView.ShowGroupPanel = false;
            this.gridColumn9.Caption = "M\x00e3 tổ nh\x00f3m";
            this.gridColumn9.FieldName = "GroupCode";
            this.gridColumn9.Name = "gridColumn9";
            this.gridColumn9.Visible = true;
            this.gridColumn9.VisibleIndex = 0;
            this.gridColumn10.Caption = "T\x00ean tổ nh\x00f3m";
            this.gridColumn10.FieldName = "GroupName";
            this.gridColumn10.Name = "gridColumn10";
            this.gridColumn10.Visible = true;
            this.gridColumn10.VisibleIndex = 1;
            this.cboPosition.Location = new Point(30, 120);
            this.cboPosition.Name = "cboPosition";
            this.cboPosition.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboPosition.Properties.NullValuePrompt = "[Chọn chức vụ cho nh\x00e2n vi\x00ean]";
            this.cboPosition.Properties.NullValuePromptShowForEmptyValue = true;
            this.cboPosition.Properties.PopupSizeable = true;
            this.cboPosition.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
            this.cboPosition.Size = new Size(0x108, 20);
            this.cboPosition.TabIndex = 6;
            this.grOld.Controls.Add(this.txtPosition);
            this.grOld.Controls.Add(this.cboGroup);
            this.grOld.Controls.Add(this.cboDepartment);
            this.grOld.Controls.Add(this.cboBranch);
            this.grOld.Location = new Point(13, 60);
            this.grOld.Name = "grOld";
            this.grOld.Size = new Size(0x105, 0x9a);
            this.grOld.TabIndex = 3;
            this.grOld.TabStop = false;
            this.grOld.Text = "Cũ";
            this.txtPosition.EditValue = "[Chức danh hiện tại]";
            this.txtPosition.Location = new Point(0x10, 0x79);
            this.txtPosition.Name = "txtPosition";
            this.txtPosition.Properties.ReadOnly = true;
            this.txtPosition.Size = new Size(0xe9, 20);
            this.txtPosition.TabIndex = 3;
            this.cboGroup.EditValue = "[Tổ nh\x00f3m]";
            this.cboGroup.Location = new Point(0x10, 90);
            this.cboGroup.Name = "cboGroup";
            this.cboGroup.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboGroup.Properties.ReadOnly = true;
            this.cboGroup.Size = new Size(0xe9, 20);
            this.cboGroup.TabIndex = 2;
            this.cboDepartment.EditValue = "[Ph\x00f2ng ban]";
            this.cboDepartment.Location = new Point(0x10, 0x3b);
            this.cboDepartment.Name = "cboDepartment";
            this.cboDepartment.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboDepartment.Properties.ReadOnly = true;
            this.cboDepartment.Size = new Size(0xe9, 20);
            this.cboDepartment.TabIndex = 1;
            this.cboBranch.EditValue = "[Chi nh\x00e1nh]";
            this.cboBranch.Location = new Point(0x10, 0x19);
            this.cboBranch.Name = "cboBranch";
            this.cboBranch.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboBranch.Properties.ReadOnly = true;
            this.cboBranch.Size = new Size(0xe9, 20);
            this.cboBranch.TabIndex = 0;
            this.lcReason.Location = new Point(15, 230);
            this.lcReason.Name = "lcReason";
            this.lcReason.Size = new Size(0x48, 13);
            this.lcReason.TabIndex = 5;
            this.lcReason.Text = "L\x00fd do thay đổi:";
            this.lcDecideNumber.Location = new Point(0x10, 0x112);
            this.lcDecideNumber.Name = "lcDecideNumber";
            this.lcDecideNumber.Size = new Size(70, 13);
            this.lcDecideNumber.TabIndex = 7;
            this.lcDecideNumber.Text = "Số quyết định:";
            this.lcPerson.Location = new Point(0x163, 0x114);
            this.lcPerson.Name = "lcPerson";
            this.lcPerson.Size = new Size(80, 13);
            this.lcPerson.TabIndex = 11;
            this.lcPerson.Text = "Người ban h\x00e0nh:";
            this.cboDecideNumber.Location = new Point(0x5b, 0x10f);
            this.cboDecideNumber.Name = "cboDecideNumber";
            this.cboDecideNumber.Size = new Size(0x55, 20);
            this.cboDecideNumber.TabIndex = 8;
            this.cboPerson.Location = new Point(0x1b6, 0x111);
            this.cboPerson.Name = "cboPerson";
            this.cboPerson.Size = new Size(0x97, 20);
            this.cboPerson.TabIndex = 12;
            this.txtReason.Location = new Point(0x5b, 0xe3);
            this.txtReason.Name = "txtReason";
            this.txtReason.Size = new Size(0x1f2, 0x23);
            this.txtReason.TabIndex = 6;
            this.txtReason.TabStop = false;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.grInformation);
            base.Name = "xucPositionAdd";
            base.Size = new Size(0x25b, 0x15c);
            base.Controls.SetChildIndex(base.btnCancel, 0);
            base.Controls.SetChildIndex(base.btnSave, 0);
            base.Controls.SetChildIndex(base.btnSaveNew, 0);
            base.Controls.SetChildIndex(this.grInformation, 0);
            ((ISupportInitialize) base.Err).EndInit();
            base.imageCollection2.EndInit();
            this.grInformation.EndInit();
            this.grInformation.ResumeLayout(false);
            this.grInformation.PerformLayout();
            this.txtEmployeeName.Properties.EndInit();
            this.glkEmployeeCode.Properties.EndInit();
            this.gridView1.EndInit();
            this.dtDate.Properties.VistaTimeProperties.EndInit();
            this.dtDate.Properties.EndInit();
            this.grNew.ResumeLayout(false);
            this.grNew.PerformLayout();
            this.glkBranch.Properties.EndInit();
            this.gridLookUpEdit1View.EndInit();
            this.glkDepartment.Properties.EndInit();
            this.gridView4.EndInit();
            this.glkGroup.Properties.EndInit();
            this.gridView5.EndInit();
            this.cboPosition.Properties.EndInit();
            this.grOld.ResumeLayout(false);
            this.txtPosition.Properties.EndInit();
            this.cboGroup.Properties.EndInit();
            this.cboDepartment.Properties.EndInit();
            this.cboBranch.Properties.EndInit();
            this.cboDecideNumber.Properties.EndInit();
            this.cboPerson.Properties.EndInit();
            this.txtReason.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void InitMultiLanguages()
        {
            this.grInformation.Text = MultiLanguages.GetString("tbl_ProcessPositionAdd", "grInformation", this.grInformation.Text);
            this.grOld.Text = MultiLanguages.GetString("tbl_ProcessPositionAdd", "grOld", this.grOld.Text);
            this.grNew.Text = MultiLanguages.GetString("tbl_ProcessPositionAdd", "grNew", this.grNew.Text);
            this.cboBranch.Properties.NullText = MultiLanguages.GetString("tbl_ProcessPositionAdd", "OldBranch", this.cboBranch.Properties.NullText);
            this.cboDepartment.Properties.NullText = MultiLanguages.GetString("tbl_ProcessPositionAdd", "OldDepartment", this.cboDepartment.Properties.NullText);
            this.cboGroup.Properties.NullText = MultiLanguages.GetString("tbl_ProcessPositionAdd", "OldGroup", this.cboGroup.Properties.NullText);
            this.txtPosition.Properties.NullText = MultiLanguages.GetString("tbl_ProcessPositionAdd", "OldPosition", this.txtPosition.Properties.NullText);
            this.glkBranch.Properties.NullText = MultiLanguages.GetString("tbl_ProcessPositionAdd", "NewBranch", this.glkBranch.Properties.NullText);
            this.glkDepartment.Properties.NullText = MultiLanguages.GetString("tbl_ProcessPositionAdd", "NewDepartment", this.glkDepartment.Properties.NullText);
            this.glkGroup.Properties.NullText = MultiLanguages.GetString("tbl_ProcessPositionAdd", "NewGroup", this.glkGroup.Properties.NullText);
            this.cboPosition.Properties.NullText = MultiLanguages.GetString("tbl_ProcessPositionAdd", "NewPosition", this.cboPosition.Properties.NullText);
            this.lcReason.Text = MultiLanguages.GetString("tbl_ProcessPositionAdd", "Reason", this.lcReason.Text);
            this.lcDate.Text = MultiLanguages.GetString("tbl_ProcessPositionAdd", "Date", this.lcDate.Text);
            this.lcDecideNumber.Text = MultiLanguages.GetString("tbl_ProcessPositionAdd", "DecideNumber", this.lcDecideNumber.Text);
            this.lcPerson.Text = MultiLanguages.GetString("tbl_ProcessPositionAdd", "Person", this.lcPerson.Text);
        }

        private void labelControl7_Click(object sender, EventArgs e)
        {
        }

        private void LoadEmployeeInformation()
        {
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.m_EmployeeCode);
            this.cboBranch.Text = hrm_employee.BranchName;
            this.cboDepartment.Text = hrm_employee.DepartmentName;
            this.cboGroup.Text = hrm_employee.GroupName;
            this.glkBranch.EditValue = hrm_employee.BranchCode;
            this.txtPosition.Text = hrm_employee.Position;
            hrm_employee.Get(this.m_EmployeeCode);
            this.grInformation.Text = "Th\x00f4ng Tin Thay Đổi Chức Vụ - " + hrm_employee.EmployeeCode + " (" + hrm_employee.FirstName + " " + hrm_employee.LastName + ")";
            this.txtEmployeeName.Text = hrm_employee.FirstName + " " + hrm_employee.LastName;
        }

        private void RaiseSuccessEventHander(HRM_PROCESS_POSITION item)
        {
            if (this.Success != null)
            {
                this.Success(this, item);
            }
        }

        public void SetCode(string EmployeeCode)
        {
            this.m_EmployeeCode = EmployeeCode;
            if (this.m_EmployeeCode != "")
            {
                this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
                this.LoadEmployeeInformation();
            }
        }

        public void SetData(HRM_PROCESS_POSITION item)
        {
            this.m_PositionID = item.PositionID;
            SYS_LOG.Insert("Tai Nạn Lao Động", "Xem", this.m_PositionID.ToString());
            this.m_EmployeeCode = item.EmployeeCode;
            this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
            this.glkEmployeeCode.Enabled = false;
            this.cboBranch.Text = item.OldBranch;
            this.cboDepartment.Text = item.OldDepartment;
            this.cboGroup.Text = item.OldGroup;
            this.txtPosition.Text = item.OldPosition;
            this.glkBranch.EditValue = item.NewBranch;
            this.glkDepartment.EditValue = item.NewDepartment;
            this.glkGroup.EditValue = item.NewGroup;
            this.cboPosition.Text = item.NewPosition;
            this.dtDate.DateTime = item.Date;
            this.txtReason.Text = item.Reason;
            this.cboDecideNumber.Text = item.DecideNumber;
            this.cboPerson.Text = item.Person;
        }

        protected override string uc_Change()
        {
            return string.Empty;
        }

        protected override string uc_Delete()
        {
            HRM_PROCESS_POSITION item = new HRM_PROCESS_POSITION {
                PositionID = this.m_PositionID
            };
            string str = item.Delete();
            if (str == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            return str;
        }

        protected override string uc_Save()
        {
            if (MyRule.Get(MyLogin.RoleId, "bbiProcessPosition") != "OK")
            {
                return "";
            }
            if (!MyRule.AllowAdd)
            {
                MyRule.Notify();
                return "";
            }
            if (this.m_EmployeeCode == "")
            {
                XtraMessageBox.Show("Vui l\x00f2ng chọn nh\x00e2n vi\x00ean để lưu dữ liệu!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK);
                return "";
            }
            if ((this.glkBranch.EditValue == null) || (this.glkBranch.Text == ""))
            {
                XtraMessageBox.Show("Vui l\x00f2ng chọn ph\x00f2ng ban mới cho nh\x00e2n vi\x00ean n\x00e0y!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK);
                return "";
            }
            if (this.cboPosition.EditValue == null)
            {
                XtraMessageBox.Show("Vui l\x00f2ng chọn chức vụ mới cho nh\x00e2n vi\x00ean n\x00e0y!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK);
                return "";
            }
            SYS_LOG.Insert("Tai Nạn Lao Động", "Th\x00eam", this.m_PositionID.ToString());
            base.SetWaitDialogCaption("Đang lưu dữ liệu...");
            Cursor.Current = Cursors.WaitCursor;
            HRM_PROCESS_POSITION item = new HRM_PROCESS_POSITION {
                PositionID = Guid.NewGuid(),
                EmployeeCode = this.m_EmployeeCode,
                OldBranch = this.cboBranch.Text,
                OldDepartment = this.cboDepartment.Text,
                OldGroup = this.cboGroup.Text,
                OldPosition = this.txtPosition.Text,
                NewBranch = this.glkBranch.EditValue.ToString()
            };
            if (this.glkDepartment.EditValue != null)
            {
                item.NewDepartment = this.glkDepartment.EditValue.ToString();
            }
            else
            {
                item.NewDepartment = "";
            }
            if (this.glkGroup.EditValue != null)
            {
                item.NewGroup = this.glkGroup.EditValue.ToString();
            }
            else
            {
                item.NewGroup = "";
            }
            item.NewPosition = this.cboPosition.Text;
            item.Date = this.dtDate.DateTime;
            item.Reason = this.txtReason.Text;
            item.DecideNumber = this.cboDecideNumber.Text;
            item.Person = this.cboPerson.Text;
            string text = item.Insert();
            if (text == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            Cursor.Current = Cursors.Default;
            this.DoHide();
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                this.Update(this.glkBranch.Properties.View.GetFocusedRowCellValue("BranchCode").ToString(), (item.NewDepartment != "") ? this.glkDepartment.Properties.View.GetFocusedRowCellValue("DepartmentCode").ToString() : "", (item.NewGroup != "") ? this.glkGroup.Properties.View.GetFocusedRowCellValue("GroupCode").ToString() : "", item.NewPosition);
            }
            return text;
        }

        protected override string uc_Update()
        {
            if (MyRule.Get(MyLogin.RoleId, "bbiProcessPosition") != "OK")
            {
                return "";
            }
            if (!MyRule.AllowEdit)
            {
                MyRule.Notify();
                return "";
            }
            SYS_LOG.Insert("Tai Nạn Lao Động", "Cập Nhật", this.m_PositionID.ToString());
            base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
            HRM_PROCESS_POSITION item = new HRM_PROCESS_POSITION {
                PositionID = this.m_PositionID,
                EmployeeCode = this.m_EmployeeCode,
                OldBranch = this.cboBranch.Text,
                OldDepartment = this.cboDepartment.Text,
                OldGroup = this.cboGroup.Text,
                OldPosition = this.txtPosition.Text,
                NewBranch = this.glkBranch.EditValue.ToString()
            };
            if (this.glkDepartment.EditValue != null)
            {
                item.NewDepartment = this.glkDepartment.EditValue.ToString();
            }
            else
            {
                item.NewDepartment = "";
            }
            if (this.glkGroup.EditValue != null)
            {
                item.NewGroup = this.glkGroup.EditValue.ToString();
            }
            else
            {
                item.NewGroup = "";
            }
            item.NewPosition = this.cboPosition.Text;
            item.Date = this.dtDate.DateTime;
            item.Reason = this.txtReason.Text;
            item.DecideNumber = this.cboDecideNumber.Text;
            item.Person = this.cboPerson.Text;
            string text = item.Update();
            if (text == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                this.Update(this.glkBranch.Properties.View.GetFocusedRowCellValue("BranchCode").ToString(), (item.NewDepartment != "") ? this.glkDepartment.Properties.View.GetFocusedRowCellValue("DepartmentCode").ToString() : "", (item.NewGroup != "") ? this.glkGroup.Properties.View.GetFocusedRowCellValue("GroupCode").ToString() : "", item.NewPosition);
            }
            this.DoHide();
            return text;
        }

        private void Update(string BranchCode, string DepartmentCode, string GroupCode, string Position)
        {
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.m_EmployeeCode);
            hrm_employee.BranchCode = BranchCode;
            hrm_employee.DepartmentCode = DepartmentCode;
            hrm_employee.GroupCode = GroupCode;
            hrm_employee.Position = Position;
            hrm_employee.Update();
        }

        public delegate void SuccessEventHander(object sender, HRM_PROCESS_POSITION item);
    }
}

